﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Fashion.Common.Method;
using Fashion.Models;

namespace Fashion.Controllers
{
    public class BaseController : Controller
    {
        public ActionResult RedirectToLogin()
        {
            return RedirectToAction("Login", "Account", new { returnUrl = Request.Path });
        }

        public ActionResult RedirectToHomePage()
        {
            return RedirectToAction("Index", "Home");
        }

        public Account CurrentUser
        {
            get 
            { 
                var principal = User as EnhancedPrincipal;
                return principal == null ? null : principal.Data;
            }
        }

        public string GetQueryString(string name)
        {
            return Request.QueryString[name];
        }

        public PartialViewResult UsrCategory()
        {
            var repository = new ProductCategoryRepository();
            var model = repository.GetAllCategoryParent().OrderBy(i=>i.OrderDisplay);
            return PartialView(model);
        }
    }
}
